import Axios from "axios";

// 创建axios实例
const axios = Axios.create({
  // baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000 // 超时
});

// 请求拦截
axios.interceptors.request.use(
  config => {
    const token = localStorage.getItem('token')
    if (token) {
      config.headers["Authorization"] = token;
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);

// 响应拦截
axios.interceptors.response.use(
  response => {
    return response.data;
  },
  error => {
    return Promise.reject(error);
  }
);

export default axios;
